#define  _CRT_SECURE_NO_WARNINGS 1
#include "Stack.h"
#include "Queue.h"

void text1()
{
	Stack st;
	StackInit(&st);
	StackPush(&st, 1);
	StackPush(&st, 2);
	StackPush(&st, 3);
	StackPush(&st, 4);

	while (!StackEmpty(&st))
	{
		printf("%d ", StackTop(&st));
		StackPop(&st);
	}
	printf("\n");

	StackDestroy(&st);

}

bool isValid(char* s) {
    Stack st;
    StackInit(&st);
    char top;
    while (*s)
    {
        if ((*s == '(') || (*s == '[') || (*s == '{'))
        {
            StackPush(&st, *s);
        }
        else
        {

            if (StackEmpty(&st))
            {
                StackDestroy(&st);
                return false;
            }

            top = StackTop(&st);
            StackPop(&st);
            if ((*s == ']' && top != '[')
                || (*s == '}' && top != '{')
                || (*s == ')' && top != '('))
            {
                StackDestroy(&st);
                return false;
            }
        }

        ++s;
    }

    bool ret = StackEmpty(&st);
    StackDestroy(&st);

    return ret;
}

void test2()
{
    Queue pq;
    QueueInit(&pq);

    QueuePush(&pq, 1);
    QueuePush(&pq, 2);
    QueuePush(&pq, 3);
    QueuePush(&pq, 4);

    //while (!QueueEmpty(&pq))
    //{
    //    printf("%d ", QueueFront(&pq));
    //    QueuePop(&pq);
    //}

    int back = QueueBack(&pq);
    printf("%d ", back);


    QueueDestroy(&pq);

}

int main()
{
	/*text1();
    printf("%d\n", isValid("()[]{}"));*/

    test2();
	return 0;
}